package kr.hkit.powerjava.chapter14.window;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.BoxLayout;
import javax.swing.JButton;

public class BoxFrame extends JFrame {

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BoxFrame frame = new BoxFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BoxFrame() {
		initialize();
	}
	private void initialize() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		JPanel contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane); //setVisible 안해도 되는 이유..?
		contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
		
		makeButton(contentPane, "Buuton 01");
		makeButton(contentPane, "Buuton 02");
		makeButton(contentPane, "Buuton 03");
		makeButton(contentPane, "Buuton 04");
		makeButton(contentPane, "Buuton 05");
		
		
	}

	
		private void makeButton(JPanel panel, String text) {
			JButton button = new JButton(text);
			button.setAlignmentX(Component.CENTER_ALIGNMENT);
			panel.add(button);
		}
}
